// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { game } from "../../../../script/game/control/game";
import { ccs } from "../../../../script/util/services";
import { touchExd } from "../../../../script/util/TouchExtend";
import { WinBase } from "../../../../script/wins/WinBase";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends WinBase {

    start () {
        ccs.gf.extendNodeName(this.nodes, this.node.parent);
        this.setEvent();
    }

    setEvent() {
        touchExd.touchEvent(this.nodes.close, () => {
            this.nodes.tips.active = false;
        })
        // this.touchEndEventScale(this.nodes.load, () => {
        //     ccs.winMgr.closeAllWin();
        //     game.gameMgr.loadGame();
        //     ccs.winMgr.showWin("mainWin");
        // })
        this.touchEndEventScale(this.nodes.restart, () => {
            ccs.winMgr.showWin("popAlert", {title: "警告", "content": "确定重新开始吗？（重进游戏即可）", cb: () => {
                cc.game.end();
            }})
        })
        this.touchEndEventScale(this.nodes.rank, () => {
            ccs.winMgr.showWin("rankWin");
        })
        this.touchEndEventScale(this.nodes.exit, () => {
            
            ccs.winMgr.showWin("popAlert", {title: "警告", "content": "确定退出游戏吗？", cb: () => {
                cc.game.end();
            }})
        })
        this.touchEndEventScale(this.nodes.music, () => {
            game.gameMgr.changeMusic();
        })
        this.touchEndEventScale(this.nodes.support, () => {
            // return ccs.winMgr.showWin("toast", {msg: "感谢大佬的支持"});
            this.nodes.tips.active = false;
        })
    }
    // update (dt) {}
}
